package xaj.puiatti.ast;

import polyglot.lex.Identifier;
import polyglot.util.CodeWriter;
import polyglot.util.Position;
import polyglot.visit.PrettyPrinter;
import abc.aspectj.ast.DeclareDecl_c;

public class PCRule_c extends DeclareDecl_c implements PCRule {

    Identifier id1;
    Identifier id2;
    RuleCond rc;
    DeclRuleBody b;

	public PCRule_c(Position pos, Identifier id1, Identifier id2, RuleCond rc, DeclRuleBody b) {
		super(pos);
		this.id1 = id1;
		this.id2 = id2;
	    this.rc = rc;
	    this.b = b;
	}

	@Override
    public Identifier getIdent1() {
        return id1;
	}

	@Override
    public Identifier getIdent2() {
        return id2;
	}

	@Override
    public void prettyPrint(CodeWriter w, PrettyPrinter tr) {

        w.write("declare rule " + id1.getIdentifier());

        if(id2 != null){
            w.write(" extends " + id2.getIdentifier());
        	
        }
    	   
        w.write(" : ");
        w.allowBreak(0);

        print(rc, w, tr);
        print(b, w, tr);

        w.write(" ;");
        w.end();
    }
}
